/*
 * @lc app=leetcode.cn id=1089 lang=cpp
 *
 * [1089] 复写零
 */

// @lc code=start
class Solution {
public:
    void duplicateZeros(vector<int>& arr) {
        vector<int> tmp(arr.size());
        for(int i = 0, j = 0; i < arr.size() && j < arr.size(); i++)
        {
            if(arr[i] == 0)
            {
                tmp[j++] = 0;
                if(j < arr.size())
                    tmp[j++] = 0;
            }
            else
                tmp[j++] = arr[i];
        }
        arr = tmp;
    }
};
// @lc code=end

